\name{logmar}
\alias{logmar}
\title{Logarithm of the Minimum Angle of Resolution}
\description{
Calculate the logMAR values from a Snellen fraction (e.g., 20/20) or go from a logMAR value back to a Snellen chart fraction.  This is an internal function and is not typically meant to be called directly.}
\usage{
logmar(x, snell.numerator = 20, inverse = FALSE)
}
\arguments{
  \item{x}{\code{x} the input.  May be the denominator of a Snellen fraction or a logMAR value (if \code{inverse = TRUE}).
}
  \item{snell.numerator}{The numerator of a Snellen fraction.  It defaults to 20 (the most common one).
}
  \item{inverse}{\code{inverse} = FALSE by default.  If TRUE, \code{logmar} will assume \code{x} is a logMAR value, and calculate the denominator of a Snellen fraction using the \code{snell.numerator} as the numerator.  See "Details".
}
}
\details{
  This function is one of several designed to help convert measures of visual acuity recorded typically recorded as Snellen fractions (e.g., 20/20 sees at 20 feet what is "typically" seen at 20 feet.  20/40 sees at 20 feet what is "typically" seen at 40 feet, etc.) into statistically usable data.  Other functions are responsible for suitably parsing the text and passing numbers to \code{logmar}.
  If \code{inverse = FALSE} (the default), \code{logmar} calculates \eqn{-log_{10}(\frac{snell.numerator}{x})}{-log10(snell.numerator/x)}.  If \code{TRUE}, then \eqn{\frac{snell.numerator}{10^{-x}}}{snell.numerator/(10 ^ -x)}.
}
\value{A numeric vector with the logMAR values or the denominator of a Snellen fraction if \code{inverse = TRUE}.
}
\references{Jack T. Holladay (2004).  Visual acuity measurements.  \emph{Journal of Cataract & Refractive Surgery, 30}(2), pp. 287--290. DOI: 10.1016/j.jcrs.2004.01.014.  \url{http://www.sciencedirect.com/science/article/B6VSF-4BX5RWS-2/2/c76a1a79f122eed8ace7be814131f749}}
\author{Joshua Wiley, \url{http://joshuawiley.com/}}
\note{This was written in conjunction with several other functions to deal with a very specific style of recording visual acuity for a study I worked on.  It may or may not have much use elsewhere.  \code{logmar} was not intended to typically be called by the user directly.  Generally, a higher level function, (e.g., \code{VAConverter}) would be called on Snellen or decimal values and it would eventually pass values to \code{logmar}.
}
\seealso{\code{\link{VAConverter}} the overall function typically called, \code{\link{CFHM}} to parse CF or HM data to pass to \code{logmar}, \code{\link{snellen}} to parse Snellen values (and linearly interpolate if necessary) to pass to \code{logmar}.}
\examples{
## logMAR value for "perfect" 20/20 vision
Jmisc:::logmar(x = 20)

## Go to and from logMAR value, should return "20"
## there may be slight error due to floating point arithmetic
Jmisc:::logmar(x = Jmisc:::logmar(x = 20), inverse = TRUE)

## logMAR value for 20/40 vision
Jmisc:::logmar(40)
}
\keyword{misc}
